package com.bbkb.quartz.vo;



import java.util.Collections;
import java.util.List;

public class Result {

    private boolean success = false;

    private String code = "999";

    private String msg = "系统异常";

    /**
     * 总条数
     */
    private long total = 0;

    /**
     * 返回的数据
     */
    private List rows = Collections.emptyList();

    /**
     * 额外对象
     */
    private Object data;

    public Result() {
    }

    public Result(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Object data) {
        this.code = "00";
        this.msg = "结果正常";
        this.success = true;
        this.data = data;
    }

    public Result(long total, List rows) {
        this.code = "00";
        this.msg = "结果正常";
        this.success = true;
        this.total = total;
        this.rows = rows;
    }

    public static Result success() {
        return new Result(null);
    }

    public static Result success(Object data) {
        return new Result(data);
    }

    public static Result success(long total, List rows) {
        return new Result(total, rows);
    }

    public static Result error() {
        return new Result();
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setMsg(msg);
        return result;
    }

    public static Result error(String code, String msg) {
        return new Result(code, msg);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List getRows() {
        return rows;
    }

    public void setRows(List rows) {
        this.rows = rows;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
